<template>
	<web-view :src="urlP"></web-view>
</template>

<script>
	import {
		findByOutId
	} from '../../api/user';
	import config from '../../common/config'

	export default {
		data() {
			var url = uni.getStorageSync("webView") || config.base + "/mplogin/miniopenid"
			//{miniopenid}
			var login = false;

			if (url.indexOf("miniopenid") > -1) {
				var userInfo = uni.getStorageSync("userInfo")
				url = url.replace("miniopenid", userInfo['openId'])
				login = true
			}
			console.log(url)
			return {
				login: login,
				urlP: url
			}
		},
		onBackPress() {
			console.log("HHHH")
		},
		onBack: function() {
			console.log("Back")
		},
		onNavigationBarButtonTap() {
			console.log("HHHHHHHH01")
		},
		onUnload() {
			console.log("OnHide")
		},
		onShow() {
			if (this.login) {
				findByOutId(this.userInfo.id).then(res => {
					if (res.mpSubscribe == 1) {
						wx.reLaunch({
							url: '/pages/index/index'
						})
					}
				})
			}
		}


	}
</script>

<style>
</style>